#!/bin/bash

if [[ ! -d ~/.config ]]; then
    mkdir -p ~/.config
fi

cd ~/.config

if [[ -d nvim ]]; then
    suffix=$(date +'%Y-%m-%d_%H%M%S')
    mv nvim nvim.${suffix}
fi

if [[ ! -d laxlinuxcfg ]]; then
    echo "开始下载配置"
    git clone -b master --depth 1 https://gitee.com/tsfissure/laxlinuxcfg.git
    (( $? != 0 )) && echo "下载配置失败,请手动下载: https://gitee.com/tsfissure/laxlinuxcfg.git " && exit 1
    echo "下载成功"
fi
ln -svf laxlinuxcfg/nvim .

#sed -i 's:github.com:hub.fastgit.xyz:g' ~/.config/nvim/autoload/plug.vim
vim -c PlugInstall
cd ~/.config/nvim/plugged/coc.nvim && yarn install && yarn build
echo "配置完成, Enjoy!"

